//
//  NSString+LabelHeight.m
//  kqpai
//
//  Created by 辰领科技 on 16/6/21.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "NSString+LabelHeight.h"

@implementation NSString (LabelHeight)

- (CGFloat)TextSizeWith:(UIFont *)font totalSize:(CGSize)totalSize {
    NSStringDrawingOptions opts = NSStringDrawingUsesLineFragmentOrigin |
    NSStringDrawingUsesFontLeading;
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    [style setLineBreakMode:NSLineBreakByCharWrapping];
    
    NSDictionary *attributes = @{ NSFontAttributeName :font, NSParagraphStyleAttributeName :style};
    
    
    CGSize size = [self boundingRectWithSize:totalSize
                                     options:opts
                                  attributes:attributes
                                     context:nil].size;
    
    return ceil(size.height);
    
}

@end
